﻿package mortal.game.view.copy.sunbathCopy.render
{
    import Message.Public.*;
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.component.gconst.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;

    public class SunbathOprBtn extends GSprite
    {
        protected var _bgBtn:GLoadingButton;
        protected var _nameBg:GBitmap;
        protected var num:GTextFiled;
        private var _info:Object;

        public function SunbathOprBtn()
        {
            var _loc_1:Boolean = true;
            this.mouseEnabled = true;
            this.mouseChildren = _loc_1;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._bgBtn = UIFactory.gLoadingButton(ImagesConst.SunbathCopyItemBtn2_upSkin, 0, 0, 100, 80, this);
            this._bgBtn.label = "";
            this._nameBg = UIFactory.gBitmap(ImagesConst.SunbathCopyTxt6, 13, 43, this);
            this.num = UIFactory.gTextField("1/3", -8, 21, 100, 20, this, GlobalStyle.textFormatLv.center());
            var _loc_1:Boolean = false;
            this.num.mouseEnabled = false;
            this.num.selectable = _loc_1;
            this._bgBtn.configEventListener(MouseEvent.CLICK, this.onCkHd);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._bgBtn = null;
            this._nameBg = null;
            this.num = null;
            return;
        }// end function

        public function updateInof(param1:Object) : void
        {
            this._info = param1;
            if (param1 != null)
            {
                if (this._nameBg)
                {
                    this._nameBg.dispose();
                }
                this._nameBg = UIFactory.gBitmap(param1["nameBg"], 13, 43, this);
                this.num.text = Language.getStringByParam(70966, 0);
            }
            return;
        }// end function

        public function updateNum(param1:Object) : void
        {
            this._info = param1;
            if (param1 != null)
            {
                if (ESunbathOper._ESunbathOperDance == param1["type"])
                {
                    this.num.text = "";
                }
                else if (ESunbathOper._ESunbathOperPerform == param1["type"])
                {
                    if (param1["num1"] <= 0)
                    {
                        this.num.text = "";
                    }
                    else
                    {
                        this.num.text = Language.getStringByParam(70966, param1["num1"]);
                    }
                }
                else
                {
                    this.num.text = Language.getStringByParam(70966, param1["num1"]);
                    if (param1["num1"] <= 0)
                    {
                        this._bgBtn.mouseEnabled = false;
                        this._bgBtn.filters = [FilterConst.colorFilter2];
                    }
                    else
                    {
                        this._bgBtn.mouseEnabled = true;
                        this._bgBtn.filters = null;
                    }
                }
            }
            return;
        }// end function

        private function onCkHd(event:MouseEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.SunbathCopyOperNew, this._info));
            return;
        }// end function

    }
}
